var url = $("#searchInput").attr("url");
$("#searchInput").autocomplete({
  source:[
	  {
		  url: url + "fuzzysearch.action?searchParam=" +$("#searchInput").val(),
		  type: 'remote'
	  },
	  ["One","Two","Three"]
	  	
	/* function(q, add) {
		 alert(url);
		$.get(url + 'fuzzysearch.action', {"searchParam": $("#searchInput").val()}, function(data){
			 alert(222);
			 var match = [];
			 if (data.book != null){
				 jQuery.each(data.book, function(i, obj){
					 console.log(obj[i]);
					 match.push(obj[i]);
				 })
			 } 
			 add(match);
		 }, "json")
		 
	 }*/
  ]/*,
  focus: function(event, ui) {
	  
  },
  select: function(event, ui) {
	  $("#searchInput").val(ui.item.bookName);
  }*/
});

/*
 * 
 * minLength: 2,
  limit: 10,
  visibleLimit:10,
  valueKey: 'bookName',
  getTitle: function(row){
      return row["bookName"];
  },
  appendMethod:'replace',
 */


/**
 * 侧边导航绑定单击事件: 查看对应分类的列表
 */
$(".bookLevel").on("click", function(){
	
	var url = $(this).attr("url");
	var getCurrentBookLevel = $(this);
	
	var params = {
				"bookLevel1": getCurrentBookLevel.attr("level1"),
				"bookLevel2": getCurrentBookLevel.attr("level2"),
				"bookLevel3": getCurrentBookLevel.attr("level3")
			 }
	
	
	 var form = $('<form />', {action : url + 'home/book/list.action', method:"POST", style:"display:none;"}).appendTo('body');
	 
	 $.each(params, function(k, v) {
		 form.append('<input type="hidden" name="' + k +'" value="' + v +'" />');
	 })
	 
	 
	 form.submit();
	
})

$(document).ready(
		function() {
			//启动轮播图
			$('.am-slider').flexslider();

			//侧边导航样式
			//$("#nav-left-li").on("hover,click", function(){});
			$("li").hover(
					function() {
						$(".category-content .category-list li.first .menu-in")
								.css("display", "none");
						$(".category-content .category-list li.first")
								.removeClass("hover");
						$(this).addClass("hover");
						$(this).children("div.menu-in").css("display", "block")
					}, function() {
						$(this).removeClass("hover")
						$(this).children("div.menu-in").css("display", "none")
					});
		
			
			/**
			 * 移动端平台公告滚动触发
			 */
			if ($(window).width() < 640) {
				setInterval('autoScroll(".demo")', 3000);
			}
		
});


/**
 * 移动端走马灯
 */
function autoScroll(obj) {
	$(obj).find("ul").animate({
		marginTop : "-29px"
	}, 2000, function() {
		$(this).css({
			marginTop : "0px"
		}).find("li:first").appendTo(this);
	})
}





/**
 * 移动端: 底部导航样式
 */
$("li").click(function() {
	$(this).addClass("selected").siblings().removeClass(
			"selected");
});

